fix: "already activated" message but shell is not active#57
Conversation
StantonMatt
left a comment
There was a problem hiding this comment.
I checked this locally because the issue thread is a little mixed between “use exit rather than deactivate” and the stale environment state described in the PR.
The behavior change looks valid to me. With POETRY_ACTIVE=1 and no VIRTUAL_ENV, a focused regression probe fails on current main because Shell.activate() is not called, then passes on this branch. The existing already-active behavior is still preserved when both POETRY_ACTIVE and VIRTUAL_ENV point at the active env.
Local checks I ran on this branch:
python -m pytest -q tests/test_shell_command.pypython -m pytest -qpython -m ruff check src/poetry_plugin_shell/command.py tests/test_shell_command.pypython -m mypy src/poetry_plugin_shell/command.py tests/test_shell_command.py
I also checked the visible PR jobs individually: Ubuntu/macOS/Windows for Python 3.10-3.14 and pre-commit are all green.
One small thing I would consider before merge: the test change in this PR preserves the already-active case, but it does not directly assert the new stale POETRY_ACTIVE without VIRTUAL_ENV path. The scratch regression above passed on this branch, so this is not a behavior blocker, but adding that as a committed test would make the fix easier to protect.
Summary
Changes
Test Plan
Test 1Test 2